from django.db import models


# 准备商品列表信息的模型类
class GoodsInfo(models.Model):
    # 创建字段，字段类型...
    goodsName = models.CharField(max_length=200, verbose_name='商品名称')
    goodsDesc = models.CharField(max_length=200, null=True, verbose_name='描述')
    newPrice = models.DecimalField(max_digits=10, decimal_places=2, null=True, verbose_name='单价')
    oldPrice = models.DecimalField(max_digits=10, decimal_places=2, verbose_name='原价')
    mobile = models.CharField(max_length=11, unique=True, verbose_name='手机号')
    name = models.CharField(max_length=20, verbose_name='用户名')
    image = models.CharField(max_length=200, null=True, verbose_name='图片')
    create_time = models.DateTimeField(auto_now_add=True, verbose_name="创建时间")

    class Meta:
        db_table = 'addgooods'  # 指明数据库表名
        verbose_name = '发布'  # 在admin站点中显示的名称
        ordering = ['-create_time']

    def __str__(self):
        """定义每个数据对象的显示信息"""
        return self.name


